import request from '@/utils/request.js'

const workSpaceUrl = '/cloud-wkf-service/workspace'

const processHandleUrl = '/cloud-wkf-service/process'

// 委派
export function delegateTask(data) {
    return request({
        url: workSpaceUrl + '/delegateTask',
        method: 'post',
        data
    })
}

// 委派人完成
export function resolveTask(data) {
    return request({
        url: workSpaceUrl + '/resolveTask',
        method: 'post',
        data
    })
}

// 转办
export function assignee(data) {
    return request({
        url: workSpaceUrl + '/assignee',
        method: 'post',
        data
    })
}

// 退回
export function rollback(data) {
    return request({
        url: workSpaceUrl + '/rollback',
        method: 'post',
        data
    })
}

// 加签
export function addMulti(data) {
    return request({
        url: workSpaceUrl + '/addMulti',
        method: 'post',
        data
    })
}

// 减签
export function deleteMulti(data) {
    return request({
        url: workSpaceUrl + '/deleteMulti',
        method: 'post',
        data
    })
}

// 查到签上的人
export function queryMultiUsersInfo(data) {
    return request({
        url: workSpaceUrl + '/queryMultiUsersInfo',
        method: 'post',
        data
    })
}

// 通过流程实例id查看详情
export function getInstanceInfo(data) {
    return request({
        url: workSpaceUrl + '/process/instanceInfo',
        method: 'post',
        data
    })
}

// 获取流程定义id
export function getFlowDefinitionInfo(flowKey) {
    return request({
        url: processHandleUrl + `/definitionId/${flowKey}`,
        method: 'get',
    })
}

// 通过
export function agree(data) {
    return request({
        url: processHandleUrl + '/agree',
        method: 'post',
        data
    })
}

// 驳回
export function refuse(data) {
    return request({
        url: processHandleUrl + '/refuse',
        method: 'post',
        data
    })
}

// 撤销
export function revoke(data) {
    return request({
        url: processHandleUrl + '/revoke',
        method: 'post',
        data
    })
}


export default {
    delegateTask, resolveTask, assignee, rollback, getInstanceInfo,
    addMulti, deleteMulti, queryMultiUsersInfo, getFlowDefinitionInfo
}
